package bean; //打包

public class Triangle {
	private double edge1;
	private double edge2;
	private double edge3;

	public Triangle() {
		// 无参构造函数
	}

	public Triangle(double e1, double e2, double e3) {
		this.edge1 = e1;
		this.edge2 = e2;
		this.edge3 = e3;
	}

	public double getEdge1() {
		return edge1;
	}

	public double getEdge2() {
		return edge2;
	}

	public double getEdge3() {
		return edge3;
	}

	public void setEdge1(double edge) {
		this.edge1 = edge;
	}

	public void setEdge2(double edge) {
		this.edge2 = edge;
	}

	public void setEdge3(double edge) {
		this.edge3 = edge;
	}

	public boolean isTriangle() { // 是否构成三角形
		if (edge1 + edge2 > edge3 && edge1 + edge3 > edge2
				&& edge3 + edge2 > edge1)
			return true;
		else
			return false;
	}

	public double calArea() { // 求三角形的面积
		double p = (edge1 + edge2 + edge3) / 2;
		return Math.sqrt(p * (p - edge1) * (p - edge2) * (p - edge3));
	}
}
